import 'package:boss/common/common.dart';
import 'package:boss/provider/regist_provider.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/page/webView/web_view_page.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:boss/ui/widget/radioList/radio.dart' as radio;
import 'package:provider/provider.dart';


class RegistProtocol extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Consumer<RegistProvider>(
      builder: (context, registProvider, child) {
        return GestureDetector(
          onTap: () {
            registProvider.toggleAgreeProtocol();
          },
          child: Container(
            height: 100.w,
            alignment: Alignment.center,
            margin: EdgeInsets.symmetric(
              horizontal: 65.w,
            ),
            child: Row(
              children: <Widget>[
                radio.Radio(
                  width: 30.w,
                  height: 30.w,
                  isSelected: registProvider.isAgreeProtocol,
                ),
                Container(
                  margin: EdgeInsets.only(
                    left: 10.w,
                  ),
                  child: RichText(
                    textAlign: TextAlign.start,
                    text: TextSpan(style: TextStyleConstant().normal_1_22, children: [
                      TextSpan(text: '阅读并同意'),
                      TextSpan(
                        text: '《服务协议》',
                        style: TextStyleConstant().blue_22,
                        recognizer: TapGestureRecognizer()..onTap = () async {
                          Navigator.pushNamed(context, WebViewPage.pageName, arguments: {
                            'title': '',
                            'url': Constant.serviceAgreement,
                          });
                        },
                      ),
                      TextSpan(text: '和'),
                      TextSpan(
                        text: '《隐私档案》',
                        style: TextStyleConstant().blue_22,
                        recognizer: TapGestureRecognizer()..onTap = () async {
                          Navigator.pushNamed(context, WebViewPage.pageName, arguments: {
                            'title': '',
                            'url': Constant.privacyAgreement,
                          });
                        },
                      ),
                    ]),
                  ),
                ),
              ],
            ),
          ),
        );
      },
    );
  }
}
